var speed = $('.speedList .speedTab15')
var playTime = $('.nPlayTime .currentTime')
var duration = $('.nPlayTime .duration')
var nextLesson = $('.next_lesson a')
var videoDot = $('.examDot')
var timenote = videoDot.attr('timenote')

speed.click()

function check () {
  var close = $('.popboxes_btn a')
  if (close[0] !== undefined) {
    close.click()
  }
  if (playTime.text() === duration.text()) {
    nextLesson.click()
    window.setTimeout(function () {

      window.speed = $('.speedList .speedTab15')
      window.playTime = $('.nPlayTime .currentTime')
      window.duration = $('.nPlayTime .duration')
      window.nextLesson = $('.next_lesson a')
      window.videoDot = $('.examDot')
      window.timenote = videoDot.attr('timenote')
      speed.click()

    }, 2000)
  }
  if (playTime.text() === timenote) {
    var dismiss_exam = $('.popboxes_btn .popbtn_cancel')
    dismiss_exam.click()
  }
}

var t1 = window.setInterval(check, 5000)
